export function isInViewport (element: Element) {
  const elementRect = element.getBoundingClientRect()
  const viewportHeight
    = window.innerHeight || document.documentElement.clientHeight
  const viewportWidth
    = window.innerWidth || document.documentElement.clientWidth

  return (
    elementRect.top >= 0 &&
        elementRect.left >= 0 &&
        elementRect.bottom <= viewportHeight &&
        elementRect.right <= viewportWidth
  )
}
